﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace RequestLog_State_Middleware.Controllers
{
    public class HomeController : Controller
    {
        public IActionResult Index()
        {
            return View();
        }

        [Route("errorpage/{code:int}")]
        public IActionResult StatusCodePagesWithRedirects(int code)
        {
            ViewData["code"] = code;
            return View();
        }

        
        public IActionResult Error(int? code)
        {
            if (code.HasValue)
            {
                if (code.Value == 404 || code.Value == 500)
                {
                    return View(nameof(Error),code.ToString());
                }
            }

            return View();
        }

    }
}